package dao

import (
	"context"
	"prod/internal/model"
)

func (d *Dao) FindRetryMessages(ctx context.Context, limit int) (messages []*model.NsqMessage, err error) {
	if err = d.db.WithContext(ctx).Model(&model.NsqMessage{}).Where(
		"execute_time < now() limit ?", limit).Find(&messages).Error; err != nil {
		err = d.processSqlError(err)
		return
	}
	return
}
